/**
 *   This file is part of Java Simple Sampler.
 *
 *   Java Simple Sampler is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License.
 *
 *   Java Simple Sampler is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Java Simple Sampler.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   @author David Lapetina	
 */
package net.onirik.mao.sampler;

import java.util.List;

import javax.sound.midi.MidiDevice;

import net.onirik.mao.sampler.midi.JSSMidiReceiver;
import net.onirik.mao.sampler.midi.MidiHelper;
import net.onirik.mao.sampler.sound.WavSamplePlayer;

public class App {

	/**
	 * Main way to launch the JSS for now. Waiting for enhancements such as 
	 * - configuration files
	 * - gui
	 * - ...
	 */
	public static void main(String[] args) throws Exception {
		//under linux you may need a modprobe snd-virmidi before starting application.
		//other midi devices do not seem to be seen.
		@SuppressWarnings("rawtypes")
		List devices = MidiHelper.listDevices("VirMIDI [hw:1,0,1]");
		//should have only one, change the name you'd like above.
		MidiHelper helper = MidiHelper.getMidiHelper((MidiDevice.Info) devices.get(0));
		JSSMidiReceiver receiver = new JSSMidiReceiver();
		//for now add error.wav as default on channel 1 (i.e. 0 since in java we start counting at 0).
		receiver.getSamplePlayerMap(0).setDefaultPlayer(new WavSamplePlayer("sounds/error.wav"));
		//for now add info.wav as default on channel 2 (i.e. 1 since in java we start counting at 0).
		receiver.getSamplePlayerMap(1).setDefaultPlayer(new WavSamplePlayer("sounds/info.wav"));
		helper.registerReceiver(receiver);
		helper.open();
		//work is done. wait until CR 
		System.in.read();
	}

}
